package com.findFish.cage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.findFish.common.annotation.Log;
import com.findFish.common.core.controller.BaseController;
import com.findFish.common.core.domain.AjaxResult;
import com.findFish.common.enums.BusinessType;
import com.findFish.cage.domain.CageStatus;
import com.findFish.cage.service.ICageStatusService;
import com.findFish.common.utils.poi.ExcelUtil;
import com.findFish.common.core.page.TableDataInfo;

/**
 * 网箱状态Controller
 * 
 * @author admin
 * @date 2025-04-03
 */
@RestController
@RequestMapping("/cage/status")
public class CageStatusController extends BaseController
{
    @Autowired
    private ICageStatusService cageStatusService;

    /**
     * 查询网箱状态列表
     */
    @PreAuthorize("@ss.hasPermi('cage:status:list')")
    @GetMapping("/list")
    public TableDataInfo list(CageStatus cageStatus)
    {
        startPage();
        List<CageStatus> list = cageStatusService.selectCageStatusList(cageStatus);
        return getDataTable(list);
    }

    /**
     * 导出网箱状态列表
     */
    @PreAuthorize("@ss.hasPermi('cage:status:export')")
    @Log(title = "网箱状态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CageStatus cageStatus)
    {
        List<CageStatus> list = cageStatusService.selectCageStatusList(cageStatus);
        ExcelUtil<CageStatus> util = new ExcelUtil<CageStatus>(CageStatus.class);
        util.exportExcel(response, list, "网箱状态数据");
    }

    /**
     * 获取网箱状态详细信息
     */
    @PreAuthorize("@ss.hasPermi('cage:status:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(cageStatusService.selectCageStatusById(id));
    }

    /**
     * 新增网箱状态
     */
    @PreAuthorize("@ss.hasPermi('cage:status:add')")
    @Log(title = "网箱状态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CageStatus cageStatus)
    {
        return toAjax(cageStatusService.insertCageStatus(cageStatus));
    }

    /**
     * 修改网箱状态
     */
    @PreAuthorize("@ss.hasPermi('cage:status:edit')")
    @Log(title = "网箱状态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CageStatus cageStatus)
    {
        return toAjax(cageStatusService.updateCageStatus(cageStatus));
    }

    /**
     * 删除网箱状态
     */
    @PreAuthorize("@ss.hasPermi('cage:status:remove')")
    @Log(title = "网箱状态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(cageStatusService.deleteCageStatusByIds(ids));
    }
}
